// app.ts
import http from '../utils/http';
import wex from './wex'

export const store = new wex.Store({
  state: {
    userinfo:{},
    isLogin:false,
  },
  mutations: {
    setUserInfo(state,userinfo){
      state.userinfo = userinfo
    },
    setLogin(state){
      state.isLogin = true
    },
    clear(state){
      state.isLogin = false;
      state.userinfo = {};
    }
  },
  actions: {
    getUserInfo (context) {
      http.post('/info/').then((res:any)=>{
        // console.log(res)
        if(res.success){
          context.commit('setUserInfo',{
            image:res.image,
            cardid : res.cardid,
            real_name : res.real_name
          }) 
          context.commit('setLogin') 
        }
      })  
    },

  }
})



export default function(){
  wex.initial(store)
}